﻿using MaiPlanServer.IRepository;
using MaiPlanServer.Utility;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace MaiPlanServer.Repository
{
    public class BaseConnection : IBaseConnection
    {
        public SqlConnection GetConn()
        {
            var str = GetRoot("AppCode:Secret");
            var conn = new SqlConnection(str);

            return conn;
        }



        string GetRoot(string name)
        {
            var builder = new ConfigurationBuilder()
              .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
              .AddJsonFile("appsettings.json")
              .Build();

            return builder[name];
        }
    }
}
